package gugga.logging.publishers
{
	import flash.utils.getQualifiedClassName;
	
	import gugga.logging.IFilter;
	import gugga.logging.IFormatter;
	import gugga.logging.Level;
	import gugga.logging.formatters.DefaultFormatter;
	import gugga.logging.LogRecord;
	
	
	/**
	*	Standard implementation of the Logger's framework IPublisher interface.
	*	Plain text formats incoming logging messages and sends them (traces) to the output window.
	*
	*	@author Ralf Siegel
	*/
	public class TracePublisher extends BasePublisher
	{
		private var filter:IFilter;
		private var formatter:IFormatter;
		private var level:Level;
		
		/**
		*	Constructs a new trace publisher with the default formatter
		*/
		public function TraceOutput() : void
		{
			this.setFormatter(new DefaultFormatter());
		}
			
		/**
		*	@see gugga.logging.IPublisher
		*/
		public override function publish(logRecord:LogRecord):void
		{
			if (this.isLoggable(logRecord)) {
				trace(this.getFormatter().format(logRecord));
			}
		}
			
		/**
		 *	@see Object#toString() 
		 */
		public function toString():String
		{
			return "[object " + getQualifiedClassName(this) + "]";			
		}
	}
}